﻿// ReSharper disable PossibleNullReferenceException
using Ki.GoogleEarth;
using Microsoft.VisualStudio.TestTools.UnitTesting;


namespace Mother.KiTests.GoogleEarthTests
{
    [TestClass]
    public class SuperOverlayTests
    {
        [TestMethod]
        public void SuperOverlayCreation()
        {
            var vFile = KMLParts.SuperOverlay;

            Assert.IsNotNull(vFile.Element(KMLParts.Namespace + "kml"));
            Assert.IsNotNull(
                vFile.Element(KMLParts.Namespace + "kml")
                    .Element(KMLParts.Namespace + "NetworkLink")
            );
            Assert.IsNotNull(
                vFile.Element(KMLParts.Namespace + "kml")
                    .Element(KMLParts.Namespace + "NetworkLink")
                    .Element(KMLParts.Namespace + "name")
            );
            Assert.AreEqual("Super Overlay",
                            vFile.Element(KMLParts.Namespace + "kml")
                                .Element(KMLParts.Namespace + "NetworkLink")
                                .Element(KMLParts.Namespace + "name").Value
                );
            Assert.IsNotNull(vFile
                                 .Element(KMLParts.Namespace + "kml")
                                 .Element(KMLParts.Namespace + "NetworkLink")
                                 .Element(KMLParts.Namespace + "Region")
                                 .Element(KMLParts.Namespace + "LatLonAltBox")
                                 .Element(KMLParts.Namespace + "north")
                );
            Assert.AreEqual("90.00", vFile
                                 .Element(KMLParts.Namespace + "kml")
                                 .Element(KMLParts.Namespace + "NetworkLink")
                                 .Element(KMLParts.Namespace + "Region")
                                 .Element(KMLParts.Namespace + "LatLonAltBox")
                                 .Element(KMLParts.Namespace + "north").Value
                );
        }

        [TestMethod]
        public void NetworkLinkLocation()
        {
            var vFile = KMLParts.SuperOverlay;
            Assert.AreEqual("Layer0\\A000000.kml",
                            vFile
                                .Element(KMLParts.Namespace + "kml")
                                .Element(KMLParts.Namespace + "NetworkLink")
                                .Element(KMLParts.Namespace + "Link")
                                .Element(KMLParts.Namespace + "href").Value);
        }
    }
}
